﻿<template>
  <baseUI :isShow="myConfig.isShow" label="" :showLabel="false" :commonConfig="commonConfig">
    <div style="padding:10px">
      <el-tree :data="data" :props="treeProps" @node-click="handleNodeClick"></el-tree>
    </div>
  </baseUI>
</template>
<script>
import baseComponent from '../baseComponent.vue'
import baseUI from '../baseUI.vue'
import {commonUse_defaultMethod} from '../../commonUse'
export default {
  components: {
    baseComponent, baseUI
  },
  extends: baseComponent,
  mounted () {
    if (!this.isDesignMode) {
      this.load()
    }
  },
  data () {
    return {
      data: [],
      tableData: [],
      treeProps: {
        children: 'children',
        label: 'label'
      },
      pageSize: 10,
      page: 1
    }
  },
  methods: {
    isDataComponent () {
      return true
    },
    handleNodeClick (data) {
      console.log(data)
    },
    load (data) {
      if (this.myConfig.other.dataSource.metaUid) {
        let fixed_filter_express = {}
        let other_condition_express = {}
        let fixed_orderby_express = {}
        this.myConfig.other.dataSource.fixed_filter.forEach(el => {
          if (el.key) {
            if (!fixed_filter_express[el.key]) {
              fixed_filter_express[el.key] = {}
            }
            fixed_filter_express[el.key][el.op] = commonUse_defaultMethod(el.value, self.getDataObjFromPageModel(), null, null, self.parentModel)
          }
        })
        this.myConfig.other.dataSource.fixed_orderby.forEach(el => {
          if (el.key) {
            fixed_orderby_express[el.key] = el.order
          }
        })
        this.$api.mdFormQuery({
          id: this.myConfig.other.table.metaUid,
          limit: this.pageSize,
          page: this.page,
          fixed_orderby_express: fixed_orderby_express,
          fixed_filter_express: fixed_filter_express,
          other_condition_express: other_condition_express
        }).then(data => {
          this.tableData = data.data
        })
      }
    }
  },
  computed: {
  },
  watch: {
  }
}
</script>
<style lang="scss" scoped>
</style>
